"""
      获取测试数据进行请求所需要的的关键字段、
      进行请求返回结果
"""
import requests
class confighttp:
    def __init__(self,method,interfaceUrl,value):
        self.method=method
        self.interfaceUrl=interfaceUrl
        self.value=eval(value)

    def run(self):
        # 进行请求获取返会结果，将method换成大写
        if self.method.lower() == 'post':
            return self.__post()

        elif self.method.lower() == 'get':
            return self.__get()

    def __post(self):
        re=requests.post(url=self.interfaceUrl,data=self.value)
        return  re
    def __get(self):
        re=requests.get(url=self.interfaceUrl,params=self.value)
        return  re

if __name__ == '__main__':
    url = "https://www.wanandroid.com/user/login"
    method = 'post'
    value = "{'username': 'liangchao', 'password': '123456'}"
    #实例化
    ch =confighttp(method,url,value)
    re=ch.run()
    print(re.status_code)
    print(re.text)